Reconcile patch set with Gerhard. Remove special case convenience for msec();
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Jul 2013 20:21:52 +0000 (20:21 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 22 Jul 2013 20:21:52 +0000 (20:21 +0000)
we dont' do it for hours or days...Rounding in gopal. Fix botch in ggv.

12 files changed:
gpsbabel/csv_util.cc
gpsbabel/destinator.cc
gpsbabel/ggv_log.cc
gpsbabel/gopal.cc
gpsbabel/magproto.cc
gpsbabel/mapsend.cc
gpsbabel/nmea.cc
gpsbabel/reference/gopal-11-gpx.gpx
gpsbabel/src/core/datetime.h
gpsbabel/stmwpp.cc
gpsbabel/unicsv.cc
gpsbabel/waypt.cc

index 54f1d20010a0b322ef4fd89aaf2135d910e541cf..32d20370d26d90987c372851b820672c8958c611 100644 (file)
@@ -1947,7 +1947,7 @@ xcsv_waypt_pr(const waypoint* wpt)
       char tbuf[24];
       writetime(tbuf, sizeof(tbuf), "%s", wpt->GetCreationTime(), false);
       char mbuf[32];
-      snprintf(mbuf, sizeof(mbuf), "%s%03d", tbuf, wpt->GetCreationTime().msec());
+      snprintf(mbuf, sizeof(mbuf), "%s%03d", tbuf, wpt->GetCreationTime().time().msec());
       writebuff(buff, "%s", mbuf);
     }
     break;
index 67c0c0e9e4a92dae763ff155285a67edf2bdd737..e7c77d2f04386757446ca4893c4f036e83f3b085 100644 (file)
@@ -293,7 +293,6 @@ destinator_read_trk(void)
     struct tm tm;
     char buff[20];
     int date;
-    double time;
 
     recno++;
 
@@ -317,7 +316,7 @@ destinator_read_trk(void)
     gbfseek(fin, 12 * sizeof(gbint32), SEEK_CUR);      /* SAT info */
 
     date = gbfgetint32(fin);
-    time = gbfgetflt(fin);
+    double milliseconds = gbfgetflt(fin);
 
     gbfseek(fin, 2 * 12, SEEK_CUR);                    /* SAT info */
 
@@ -330,9 +329,9 @@ destinator_read_trk(void)
 
     memset(&tm, 0, sizeof(tm));
 
-    snprintf(buff, sizeof(buff), "%06d%.f", date, time);
+    snprintf(buff, sizeof(buff), "%06d%.f", date, milliseconds);
     strptime(buff, "%d%m%y%H%M%S", &tm);
-    int millisecs = (int) time % 1000;
+    int millisecs = lround(milliseconds) % 1000;
     wpt->SetCreationTime(mkgmtime(&tm), millisecs);
 
     if (wpt->fix > 0) {
@@ -436,7 +435,7 @@ destinator_trkpt_disp(const waypoint* wpt)
 
   if (wpt->creation_time) {
     struct tm tm;
-    double time;
+    double milliseconds;
     int date;
     const time_t ct = wpt->GetCreationTime();
     tm = *gmtime(&ct);
@@ -444,10 +443,11 @@ destinator_trkpt_disp(const waypoint* wpt)
     tm.tm_year -= 100;
     date = ((int)tm.tm_mday * 10000) + ((int)tm.tm_mon * 100) + tm.tm_year;
     gbfputint32(date, fout);
+    milliseconds = ((int)tm.tm_hour * 10000) + 
+                  ((int)tm.tm_min * 100) + tm.tm_sec;
+    milliseconds = (milliseconds * 1000) + (wpt->GetCreationTime().time().msec());
 
-    time = ((int)tm.tm_hour * 10000) + ((int)tm.tm_min * 100) + tm.tm_sec;
-    time = (time * 1000) + (wpt->GetCreationTime().msec());
-    gbfputflt(time, fout);
+    gbfputflt(milliseconds, fout);
   } else {
     gbfputint32(0, fout);      /* Is this invalid ? */
     gbfputflt(0, fout);
index 04efd7da0213f6c99c1bed7d94f041089846a5a9..6fc5de89db063bb7719576588e85cc1d0f9be03c 100644 (file)
@@ -238,7 +238,7 @@ ggv_log_track_head_cb(const route_head* trk)
       speed = waypt_speed(prev, wpt);
     }
     if (wpt->creation_time > 0) {
-      secs = (double)tm.tm_sec + (1000 * wpt->GetCreationTime().msec());
+      secs = (double)tm.tm_sec + wpt->GetCreationTime().time().msec() / 1000.0;
     }
 
     gbfputint16((gbint16) latint, fout);
index 710b80b8441b7ed43ce5057ff3c38822b4d83d43..48778475f5d1385bad13aa4947e8395c38677f72 100644 (file)
@@ -190,7 +190,6 @@ gopal_read(void)
   line=0;
   while ((buff = gbfgetstr(fin))) {
     int nfields;
-    unsigned long microsecs;
     if ((line == 0) && fin->unicode) {
       cet_convert_init(CET_CHARSET_UTF8, 1);
     }
@@ -214,13 +213,14 @@ gopal_read(void)
     //TICK;    TIME;   LONG;     LAT;       HEIGHT; SPEED;  Fix; HDOP;    SAT
     //3801444, 080558, 2.944362, 43.262117, 295.28, 0.12964, 2, 2.900000, 3
     c = csv_lineparse(str, ",", "", column++);
-    double millisecs = 0;
+    int millisecs = 0;
     while (c != NULL) {
       switch (column) {
       case  0: /* "-" */       /* unknown fields for the moment */
+        unsigned long microsecs;
         sscanf(c, "%lu", &microsecs);
         // Just save this; we'll use it on the next field.
-        millisecs = /*lround*/(microsecs % 1000000) / 1000.0;
+        millisecs = lround((microsecs % 1000000) / 1000.0);
         break;
       case  1:                         /* Time UTC */
         sscanf(c,"%lf",&hmsd);
index d9bdd701f135f44379ab0ca04f1a7fec30c122ab..2669fd75b4e96950b332f190bd5a8f8b256e82f3 100644 (file)
@@ -1449,7 +1449,7 @@ void mag_track_disp(const waypoint* waypointp)
             tm->tm_sec;
       date = tm->tm_mday * 10000 + tm->tm_mon * 100 +
              tm->tm_year;
-      fracsec = lround(waypointp->GetCreationTime().msec()/10.0);
+      fracsec = lround(waypointp->GetCreationTime().time().msec()/10.0);
     }
   }
   if (!tm) {
index 31c1b91e956e4be97172faed9ae5dd69cb3375b2..f479ec77addcb91116b63758692f4084f49c691b 100644 (file)
@@ -515,7 +515,7 @@ void mapsend_track_disp(const waypoint* wpt)
 
   /* 0 centiseconds */
   if (trk_version >= 30) {
-    c = lround(wpt->GetCreationTime().msec() / 10.0);
+    c = lround(wpt->GetCreationTime().time().msec() / 10.0);
     gbfwrite(&c, 1, 1, mapsend_file_out);
   }
 }
index 85af2da42cb68f045c692b3f7b80e59790aaca23..a05126a11d3e67af36453bbd545cb4b26cdd1cea 100644 (file)
@@ -1299,7 +1299,7 @@ nmea_trackpt_pr(const waypoint* wpt)
 
   if (opt_gprmc) {
     snprintf(obuf, sizeof(obuf), "GPRMC,%010.3f,%c,%08.3f,%c,%09.3f,%c,%.2f,%.2f,%06d,,",
-             (double) hms + (wpt->GetCreationTime().msec() / 1000.0),
+             (double) hms + (wpt->GetCreationTime().time().msec() / 1000.0),
              fix=='0' ? 'V' : 'A',
              fabs(lat), lat < 0 ? 'S' : 'N',
              fabs(lon), lon < 0 ? 'W' : 'E',
@@ -1318,7 +1318,7 @@ nmea_trackpt_pr(const waypoint* wpt)
   }
   if (opt_gpgga) {
     snprintf(obuf, sizeof(obuf), "GPGGA,%010.3f,%08.3f,%c,%09.3f,%c,%c,%02d,%.1f,%.3f,M,0.0,M,,",
-             (double) hms + (wpt->GetCreationTime().msec() / 1000.0),
+             (double) hms + (wpt->GetCreationTime().time().msec() / 1000.0),
              fabs(lat), lat < 0 ? 'S' : 'N',
              fabs(lon), lon < 0 ? 'W' : 'E',
              fix,
index d257e174c89e6c4e7ac21ad34df540465f44b250..4e305e9d84c0a0f5a7341492e5b622c0d07b94cc 100644 (file)
@@ -4,7 +4,7 @@
   <bounds minlat="50.307048000" minlon="8.231283000" maxlat="50.309623000" maxlon="8.232662000"/>
   <wpt lat="50.307048000" lon="8.232662000">
     <ele>341.950000</ele>
-    <time>2009-11-06T21:32:32.528Z</time>
+    <time>2009-11-06T21:32:32.529Z</time>
     <name>RPT001</name>
     <cmt>RPT001</cmt>
     <desc>RPT001</desc>
@@ -14,7 +14,7 @@
   </wpt>
   <wpt lat="50.307475000" lon="8.232442000">
     <ele>341.990000</ele>
-    <time>2009-11-06T21:32:33.529Z</time>
+    <time>2009-11-06T21:32:33.530Z</time>
     <name>RPT002</name>
     <cmt>RPT002</cmt>
     <desc>RPT002</desc>
@@ -24,7 +24,7 @@
   </wpt>
   <wpt lat="50.307902000" lon="8.232223000">
     <ele>341.813000</ele>
-    <time>2009-11-06T21:32:34.530Z</time>
+    <time>2009-11-06T21:32:34.531Z</time>
     <name>RPT003</name>
     <cmt>RPT003</cmt>
     <desc>RPT003</desc>
@@ -34,7 +34,7 @@
   </wpt>
   <wpt lat="50.308332000" lon="8.232000000">
     <ele>341.493000</ele>
-    <time>2009-11-06T21:32:35.531Z</time>
+    <time>2009-11-06T21:32:35.532Z</time>
     <name>RPT004</name>
     <cmt>RPT004</cmt>
     <desc>RPT004</desc>
@@ -44,7 +44,7 @@
   </wpt>
   <wpt lat="50.308765000" lon="8.231770000">
     <ele>341.150000</ele>
-    <time>2009-11-06T21:32:36.532Z</time>
+    <time>2009-11-06T21:32:36.533Z</time>
     <name>RPT005</name>
     <cmt>RPT005</cmt>
     <desc>RPT005</desc>
@@ -54,7 +54,7 @@
   </wpt>
   <wpt lat="50.309198000" lon="8.231532000">
     <ele>340.210000</ele>
-    <time>2009-11-06T21:32:37.533Z</time>
+    <time>2009-11-06T21:32:37.534Z</time>
     <name>RPT006</name>
     <cmt>RPT006</cmt>
     <desc>RPT006</desc>
@@ -64,7 +64,7 @@
   </wpt>
   <wpt lat="50.309623000" lon="8.231283000">
     <ele>339.163000</ele>
-    <time>2009-11-06T21:32:38.534Z</time>
+    <time>2009-11-06T21:32:38.535Z</time>
     <name>RPT007</name>
     <cmt>RPT007</cmt>
     <desc>RPT007</desc>
@@ -76,7 +76,7 @@
     <name>Tracklog Thu Jan  1 00:00:00 1970</name>
     <rtept lat="50.307048000" lon="8.232662000">
       <ele>341.950000</ele>
-      <time>2009-11-06T21:32:32.528Z</time>
+      <time>2009-11-06T21:32:32.529Z</time>
       <name>RPT001</name>
       <fix>2d</fix>
       <sat>11</sat>
@@ -84,7 +84,7 @@
     </rtept>
     <rtept lat="50.307475000" lon="8.232442000">
       <ele>341.990000</ele>
-      <time>2009-11-06T21:32:33.529Z</time>
+      <time>2009-11-06T21:32:33.530Z</time>
       <name>RPT002</name>
       <fix>2d</fix>
       <sat>11</sat>
@@ -92,7 +92,7 @@
     </rtept>
     <rtept lat="50.307902000" lon="8.232223000">
       <ele>341.813000</ele>
-      <time>2009-11-06T21:32:34.530Z</time>
+      <time>2009-11-06T21:32:34.531Z</time>
       <name>RPT003</name>
       <fix>2d</fix>
       <sat>10</sat>
     </rtept>
     <rtept lat="50.308332000" lon="8.232000000">
       <ele>341.493000</ele>
-      <time>2009-11-06T21:32:35.531Z</time>
+      <time>2009-11-06T21:32:35.532Z</time>
       <name>RPT004</name>
       <fix>2d</fix>
       <sat>11</sat>
     </rtept>
     <rtept lat="50.308765000" lon="8.231770000">
       <ele>341.150000</ele>
-      <time>2009-11-06T21:32:36.532Z</time>
+      <time>2009-11-06T21:32:36.533Z</time>
       <name>RPT005</name>
       <fix>2d</fix>
       <sat>11</sat>
     </rtept>
     <rtept lat="50.309198000" lon="8.231532000">
       <ele>340.210000</ele>
-      <time>2009-11-06T21:32:37.533Z</time>
+      <time>2009-11-06T21:32:37.534Z</time>
       <name>RPT006</name>
       <fix>2d</fix>
       <sat>11</sat>
     </rtept>
     <rtept lat="50.309623000" lon="8.231283000">
       <ele>339.163000</ele>
-      <time>2009-11-06T21:32:38.534Z</time>
+      <time>2009-11-06T21:32:38.535Z</time>
       <name>RPT007</name>
       <fix>2d</fix>
       <sat>11</sat>
index d7c535683ca5be617a42b55faadfb5bc15f457a1..929edae9e70df55a183078c44ba0428a4813c3b7 100644 (file)
@@ -75,9 +75,6 @@ public:
     return &t_;
   }
 
-  // A convenience method to return the number of milliseconds (0-999).
-  int msec() const { return this->time().msec(); }
-
   // Integer form: YYMMDD
   int ymd() const {
     QDate date(this->date());
index 30e9e9f6c52d5f2fa36adeb36bb8d1d979909844..9d3e42c7eb0186a8748cd66a202ca29d5a9eefd3 100644 (file)
@@ -273,7 +273,7 @@ stmwpp_waypt_cb(const waypoint *wpt)
     gbfprintf(fout, ".%02d", 0);
     break;
   case STM_TRKPT:
-    gbfprintf(fout, ".%03d", wpt->GetCreationTime().msec());
+    gbfprintf(fout, ".%03d", wpt->GetCreationTime().time().msec());
     break;
   }
   gbfprintf(fout, ",\r\n");
index 739aeceaa4d1f328d922e64df30978e24ac582eb..8b94a67d188a654112658cd7a2138f248e0e59bd 100644 (file)
@@ -1761,7 +1761,7 @@ unicsv_waypt_disp_cb(const waypoint *wpt)
       }
       snprintf(buf, sizeof(buf), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec);
 
-      int millisecs = wpt->GetCreationTime().msec();
+      int millisecs = wpt->GetCreationTime().time().msec();
       if (millisecs > 0) {
         int len = 3;
 
index 5c641b54cfc18a6788d6d35ac7e0d5dcc4379f24..6d06a3e40f53a5d166153dd663db4e8af1c06fa2 100644 (file)
@@ -539,7 +539,7 @@ waypt_time(const waypoint *wpt)
     return (double) 0;
   } else {
 
-    return ((double)wpt->creation_time + ((double)wpt->creation_time.msec() / 1000));
+    return ((double)wpt->creation_time + ((double)wpt->creation_time.time().msec() / 1000));
   }
 }